import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:my_app_01/pages/common/info_input.dart';
import 'package:my_app_01/pages/me/index.dart';
import 'package:my_app_01/pages/me/person_info.dart';
import 'package:my_app_01/pages/routes.dart';

import 'package:my_app_01/service/HttpUtils.dart';
import 'package:my_app_01/utils/auth.dart';

import '../config.dart';
import 'pages/app.dart';

const String pageTitle = "营养改善";

void main() async {

  String value = await LoginPrefs.init();
  HttpUtils.init(baseUrl: MyConfig.baseUrl, interceptors: [const Interceptor()]);
  if (value == 'ok') {
    return runApp(MyApp());
  }
}

final GlobalKey<NavigatorState> navigationKey = GlobalKey<NavigatorState>();

class MyApp extends StatelessWidget {

  MyApp({super.key});

  // 渲染当前控件的UI
  @override
  Widget build(BuildContext context) {
    // 每个项目最外部必有MaterialApp
    return MaterialApp(
      navigatorKey: navigationKey,

      // APP名称
      title: '测试APP',
      // APP主题
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.greenAccent,
          background: const Color.fromRGBO(252, 252, 252, 50),
        ),
        cardTheme: const CardTheme(color: Colors.white),
        useMaterial3: true,
      ),
      routes: RouterTable.routeTables,
      onGenerateRoute: RouterTable.onGenerateRoute,
      // 指定APP首页
      home: AppPage(),
      builder: EasyLoading.init(),
    );
  }
}
